var nowDate = getDay(0);
var resdata;
var url;
var trStr="";
var userId  = sessionStorage.getItem("userId");
var username = sessionStorage.getItem("name");
var BillNO = "";
//StoreNO店号  userId 操作人
$(document).ready(function(){
	window.addEventListener('pageshow', function(e) {
    if (e.persisted) {
        window.location.reload();
    }else{
	StoreName = decodeURI(decodeURI(StoreName))
	Statue = decodeURI(decodeURI(Statue))
	$('#nameh').append(StoreNO+"."+StoreName);
	$('#Statueh').append(Statue);
	$('#name').text(sessionStorage.getItem("name"));
	}
		});	
});
function pdstart(){
	$.ajax({
		url: "../../typd/pandianchaxvn_hc"
		,type:'post'
		,data:JSON.stringify({"StoreNO":StoreNO,"BeginDate":nowDate,"EndDate":nowDate})
		,contentType: "application/json; charset=utf-8"
		,dataType:'json'
		,success: function(res){
			console.log(res.data);
			if(res.data.length==0){
					console.log(111);
				pdstart1();
			}else{
				layer.msg('操作失败',{time:500},function(){
						history.go(-2);
				});
			}
		}
	});

}
function pdstart1(){	
	$.ajax({ 
		url: "../../typd/pdstart_hc"
		,type:'post'
		,data:JSON.stringify({"StoreNO":StoreNO,"OperName":username})
		,contentType: "application/json; charset=utf-8"
		,dataType:'json'
		,success: function(res){ 
			console.log(StoreNO);
			console.log(userId);
			console.log(res.data);
			BillNO = res.data[0].BillNO;
			StoreName =encodeURI(encodeURI(StoreName));
			Statue =encodeURI(encodeURI(Statue));
			url = "jh_mendianpandian_hc?BillNO="+BillNO+"&StoreNO="+StoreNO+"&StoreName="+StoreName+"&Statue="+Statue+"&nw=T";//此处拼接内容
			window.location.href = url;
		}
		,error:function(XMLHttpRequest, textStatus, errorThrown) {
		}
	});
}